package atm;


import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class ATM extends JFrame {
    private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private SavePanel savePanel = new SavePanel(this);
    private GetPanel getPanel = new GetPanel(this);
    private LookPanel lookPanel = new LookPanel(this);
    private Image bgImg = Util.getImage("/images/background.jpg");
    private CardLayout cardLayout = new CardLayout();
    private TransPanel transPanel=new TransPanel(this);
    private ChangePanel changePanel=new ChangePanel(this);


    private ArrayList<user> users=new ArrayList();

   private int a=0;

    public LoginPanel getLoginPanel() {
        return loginPanel;
    }

    public void setLoginPanel(LoginPanel loginPanel) {
        this.loginPanel = loginPanel;
    }

    public MenuPanel getMenuPanel() {
        return menuPanel;
    }

    public void setMenuPanel(MenuPanel menuPanel) {
        this.menuPanel = menuPanel;
    }

    public SavePanel getSavePanel() {
        return savePanel;
    }

    public void setSavePanel(SavePanel savePanel) {
        this.savePanel = savePanel;
    }

    public GetPanel getGetPanel() {
        return getPanel;
    }

    public void setGetPanel(GetPanel getPanel) {
        this.getPanel = getPanel;
    }

    public LookPanel getLookPanel() {
        return lookPanel;
    }

    public void setLookPanel(LookPanel lookPanel) {
        this.lookPanel = lookPanel;
    }

    public Image getBgImg() {
        return bgImg;
    }

    public void setBgImg(Image bgImg) {
        this.bgImg = bgImg;
    }

    public CardLayout getCardLayout() {
        return cardLayout;
    }

    public void setCardLayout(CardLayout cardLayout) {
        this.cardLayout = cardLayout;
    }

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    public ATM() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImg, 0, 0, 1024, 768, this);
            }
        });

        this.setSize(1024, 768);
        this.setLocationRelativeTo(this);
        this.setLayout(cardLayout);
        this.setTitle("ATM");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        this.add("login", loginPanel);
        this.add("menu", menuPanel);
        this.add("save", savePanel);
        this.add("get", getPanel);
        this.add("look", lookPanel);
        this.add("trans",transPanel);
        this.add("change",changePanel);




        this.setVisible(true);

    }

    public ArrayList<user> getUsers() {
        return users;
    }

    public void setUsers(ArrayList<user> users) {
        this.users = users;
    }

    public void init(){
        users.add(new user("张一","111",1000));
        users.add(new user("张二","222",2000));
        users.add(new user("张三","333",3000));
        users.add(new user("张四","444",4000));
        users.add(new user("张五","555",5000));
    }
    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }


    public static void main(String[] args) {
        new ATM();
        new ATM().init();
    }


}

